<include file="Public/header"/>
<include file="Public/menu"/>
<link rel="stylesheet" href="/Public/admin/adminlte/plugins/select2/select2.min.css">
<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            权限
            <small>管理</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 权限管理</a></li>
            <li class="active">添加菜单</li>
        </ol>
    </section>

    <!-- 内容 -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-info">
                    <div class="box-header with-border">
                        <h3 class="box-title">添加菜单</h3>

                        <div class="box-tools">

                            <div class="btn-group pull-right" style="margin-right: 10px">
                                <a href="{:U('admin/rbac/menu')}" class="btn btn-sm btn-default"><i
                                        class="fa fa-list"></i>&nbsp;菜单列表</a>
                            </div>
                        </div>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form action="{:U('admin/rbac/menuAdd')}" method="post" accept-charset="UTF-8"
                          class="form-horizontal" pjax-container="">

                        <div class="box-body">
                            <div class="form-group 1">
                                <label for="Continent" class="col-sm-2 control-label">导航菜单</label>
                                <div class="col-sm-6">
                                    <select class="form-control  select2-hidden-accessible" style="width: 100%;"
                                            id="Continent" name="nav_menu" tabindex="-1" aria-hidden="true">
                                        <?php foreach($nav_menu as $v) { ?>
                                        <option value="{$v['id']}">{$v['name']}</option>
                                        <?php } ?>
                                    </select>

                                </div>
                            </div>
                            <div class="form-group 1">
                                <label class="col-sm-2 control-label">菜单名称</label>
                                <div class="col-sm-6">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-pencil"></i></span>
                                        <input type="test" name="name" value="" class="form-control"
                                               placeholder="菜单名称">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group 1">
                                <label class="col-sm-2 control-label">url</label>
                                <div class="col-sm-6">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-pencil"></i></span>
                                        <input type="test" name="value" value="" class="form-control"
                                               placeholder="/组/控制器/方法">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group 1">
                                <label class="col-sm-2 control-label">组</label>
                                <div class="col-sm-6">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-pencil"></i></span>
                                        <input type="test" name="group" value="" class="form-control" placeholder="组/Admin">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group 1">
                                <label class="col-sm-2 control-label">控制器</label>
                                <div class="col-sm-6">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-pencil"></i></span>
                                        <input type="test" name="controller" value="" class="form-control"
                                               placeholder="控制器/Index">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group 1">
                                <label class="col-sm-2 control-label">方法</label>
                                <div class="col-sm-6">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-pencil"></i></span>
                                        <input type="test" name="method" value="" class="form-control" placeholder="方法/index">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <div class="col-sm-2">

                            </div>
                            <div class="col-sm-6">

                                <div class="btn-group pull-left">
                                    <button type="submit" class="btn btn-info pull-right">提交</button>
                                </div>

                                <div class="btn-group pull-right">
                                    <input type="reset" class="btn btn-warning" value="重置">
                                </div>

                            </div>

                        </div>
                        <!-- /.box-footer -->
                    </form>
                </div>

            </div>
        </div>

    </section>
</div>
<!-- 底部 -->
<include file="Public/common_footer"/>
<script src="/Public/admin/adminlte/plugins/select2/select2.full.min.js"></script>
<script data-exec-on-popstate>

    $(function () {
        $("#Continent").select2({allowClear: true});

        $('.grid-select-all').change(function () {
            if (this.checked) {
                $('.grid-item').prop("checked", true);
            } else {
                $('.grid-item').prop("checked", false);
            }
        });

        $('.batch-delete').on('click', function () {
            var selected = [];
            $('.grid-item:checked').each(function () {
                selected.push($(this).data('id'));
            });

            if (selected.length == 0) {
                return;
            }

            if (confirm("Are you sure to delete this item ?")) {
                $.post('/admin/auth/roles/' + selected.join(), {
                    _method: 'delete',
                    '_token': 'ALpaP7hXZ6s2dnAdE02Z6mUSHPt8RkYbcDRp6rpw'
                }, function (data) {
                    $.pjax.reload('#pjax-container');
                    noty({
                        text: "<strong>Succeeded!</strong>",
                        type: 'success',
                        timeout: 1000
                    });
                });
            }
        });
    });
</script>

